package com.ruoyi.web.controller.fantasy;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.huanzhidadi.fantasy.bean.domain.FantasySendEmailLog;
import com.ruoyi.fantasy.service.IFantasySendEmailLogService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;

/**
 * 邮件发送记录 信息操作处理
 * 
 * @author wanghui
 * @date 2019-07-11
 */
@Controller
@RequestMapping("/fantasy/fantasySendEmailLog")
public class FantasySendEmailLogController extends BaseController
{
    private String prefix = "fantasy/fantasySendEmailLog";
	
	@Autowired
	private IFantasySendEmailLogService fantasySendEmailLogService;
	
	@RequiresPermissions("fantasy:fantasySendEmailLog:view")
	@GetMapping()
	public String fantasySendEmailLog()
	{
	    return prefix + "/fantasySendEmailLog";
	}
	
	/**
	 * 查询邮件发送记录列表
	 */
	@RequiresPermissions("fantasy:fantasySendEmailLog:list")
	@PostMapping("/list")
	@ResponseBody
	public TableDataInfo list(FantasySendEmailLog fantasySendEmailLog)
	{
		startPage();
        List<FantasySendEmailLog> list = fantasySendEmailLogService.selectFantasySendEmailLogList(fantasySendEmailLog);
		return getDataTable(list);
	}
	
	
	/**
	 * 导出邮件发送记录列表
	 */
	@RequiresPermissions("fantasy:fantasySendEmailLog:export")
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(FantasySendEmailLog fantasySendEmailLog)
    {
    	List<FantasySendEmailLog> list = fantasySendEmailLogService.selectFantasySendEmailLogList(fantasySendEmailLog);
        ExcelUtil<FantasySendEmailLog> util = new ExcelUtil<FantasySendEmailLog>(FantasySendEmailLog.class);
        return util.exportExcel(list, "fantasySendEmailLog");
    }
	
	/**
	 * 新增邮件发送记录
	 */
	@GetMapping("/add")
	public String add()
	{
	    return prefix + "/add";
	}
	
	/**
	 * 新增保存邮件发送记录
	 */
	@RequiresPermissions("fantasy:fantasySendEmailLog:add")
	@Log(title = "邮件发送记录", businessType = BusinessType.INSERT)
	@PostMapping("/add")
	@ResponseBody
	public AjaxResult addSave(FantasySendEmailLog fantasySendEmailLog)
	{		
		return toAjax(fantasySendEmailLogService.insertFantasySendEmailLog(fantasySendEmailLog));
	}

	/**
	 * 修改邮件发送记录
	 */
	@GetMapping("/edit/{id}")
	public String edit(@PathVariable("id") Long id, ModelMap mmap)
	{
		FantasySendEmailLog fantasySendEmailLog = fantasySendEmailLogService.selectFantasySendEmailLogById(id);
		mmap.put("fantasySendEmailLog", fantasySendEmailLog);
	    return prefix + "/edit";
	}
	
	/**
	 * 修改保存邮件发送记录
	 */
	@RequiresPermissions("fantasy:fantasySendEmailLog:edit")
	@Log(title = "邮件发送记录", businessType = BusinessType.UPDATE)
	@PostMapping("/edit")
	@ResponseBody
	public AjaxResult editSave(FantasySendEmailLog fantasySendEmailLog)
	{		
		return toAjax(fantasySendEmailLogService.updateFantasySendEmailLog(fantasySendEmailLog));
	}
	
	/**
	 * 删除邮件发送记录
	 */
	@RequiresPermissions("fantasy:fantasySendEmailLog:remove")
	@Log(title = "邮件发送记录", businessType = BusinessType.DELETE)
	@PostMapping( "/remove")
	@ResponseBody
	public AjaxResult remove(String ids)
	{		
		return toAjax(fantasySendEmailLogService.deleteFantasySendEmailLogByIds(ids));
	}
	
}
